clear

global exper need4
global educ needbd_plus

global dto "change_openings_per_emp"
global initial "initialneed"
global level2000 "avgageexp"
global covars    "initialneed change_openings_per_emp avgageexp"
global stdcovars "stdinitialneed stdavgageexp stdchange_openings_per_emp"

global occfe "i.occsoc_num"
global stfe "i.statefip"
global timefe "b2012.year"

global styearfe "i.styear"
global occyearfe "i.occyear"

global restric "if minto>15 "

global flow "\parbox[c]{1.8cm}{\centering "
global lte "$\leq$"
global gte "$\geq$"

global weight "[w=occshare_state]"




use BGT_2007_2010_2012_withvars_021716_mechanisms.dta
sort statefip
tempfile a
save `a', replace

keep statefip vet_bplf1yr vet_stlf1yr year
duplicates drop
keep if year==2007
drop year
egen totalvet = sum(vet_stlf1yr)
egen totalvet_bp=sum(vet_bplf1yr)
g vetratio = vet_stlf1yr/totalvet
g vetratio_bp=vet_bplf1yr/totalvet_bp
keep statefip vetratio*
sort statefip
merge 1:m statefip using `a', nogen keep(match)

eststo clear
tsset


g nat_vet_change = ln(predicted_total/L2.predicted_total)
replace nat_vet_change=ln(predicted_total/L3.predicted_total) if nat_vet_change==.

g log_vet_var= nat_vet_change*vetshare_vsoe* vetratio
g log_vet_var_bp =nat_vet_change*vetshare_vsoe* vetratio_bp

summ dvet_supdem_bgt_bp,d
replace dvet_supdem_bgt_bp=. if dvet_supdem_bgt_bp>r(p95) | dvet_supdem_bgt_bp<r(p5)


//summ dBGTsupdemrate,d
//replace dBGTsupdemrate=. if dBGTsupdemrate>r(p95) | dBGTsupdemrate<r(p5)


			capture drop avgageexp
			gen avgageexp=bdshare2000
			capture drop initialneed
			gen initialneed=initial_needbd_plus07
			capture drop dubdage
			gen dubdage=dubd
		
			eststo: reghdfe dneedbd_plus ldvet_vsoe     i.year $weight $restric , a(occsoc_num) vce(cluster statefip)
			outreg2 ldvet_vsoe using replicationwocovars, replace 
			
			
			eststo: reghdfe dneedbd_plus ldvet_vsoe     i.year $weight $restric , a(occsoc_num statefip) vce(cluster statefip)
			outreg2 ldvet_vsoe using replicationwocovars, append 
			
			
			eststo: reghdfe dneedbd_plus log_vet_var     i.year $weight $restric , a(occsoc_num) vce(cluster statefip)
			outreg2 log_vet_var using replicationwocovars, append 
			
			
			eststo: reghdfe dneedbd_plus log_vet_var     i.year $weight $restric , a(occsoc_num statefip) vce(cluster statefip)
			outreg2 log_vet_var using replicationwocovars, append 
			
			
			eststo: reghdfe dneedbd_plus log_vet_var_bp     i.year $weight $restric , a(occsoc_num ) vce(cluster statefip)
			outreg2 log_vet_var_bp using replicationwocovars, append 
			
				
			eststo: reghdfe dneedbd_plus log_vet_var_bp     i.year $weight $restric , a(occsoc_num statefip ) vce(cluster statefip)
			outreg2 log_vet_var_bp using replicationwocovars, append 
			
			
			
			eststo: reghdfe dneedbd_plus dvet_supdem_bgt_bp     i.year $weight $restric , a(occsoc_num) vce(cluster statefip)
			outreg2 dvet_supdem_bgt_bp using replicationwocovars, append 
			
			
			eststo: reghdfe dneedbd_plus dvet_supdem_bgt_bp     i.year $weight $restric , a(occsoc_num statefip) vce(cluster statefip)
			outreg2 dvet_supdem_bgt_bp using replicationwocovars, append 
			
			
			eststo: reghdfe dneedbd_plus     i.year (dBGTsupdemrate=dvet_supdem_bgt_bp)  $weight $restric , a(occsoc_num) vce(cluster statefip)
			outreg2 dBGTsupdemrate using replicationwocovars, append 
			
			
			eststo: reghdfe dneedbd_plus     i.year  (dBGTsupdemrate=dvet_supdem_bgt_bp)  $weight $restric , a(occsoc_num statefip) vce(cluster statefip)
			outreg2 dBGTsupdemrate using replicationwocovars, append 
			
		
		
		
		
		***********************
		
		capture drop avgageexp
		gen avgageexp=avgage2000
		capture drop initialneed
		gen initialneed=initial_need407
		
		
			eststo: reghdfe dneed4 ldvet_vsoe     i.year $weight $restric , a(occsoc_num) vce(cluster statefip)
			outreg2 ldvet_vsoe using replicationwocovars, append 
			
			
			eststo: reghdfe dneed4 ldvet_vsoe     i.year $weight $restric , a(occsoc_num statefip) vce(cluster statefip)
			outreg2 ldvet_vsoe using replicationwocovars, append 
			
			
			eststo: reghdfe dneed4 log_vet_var     i.year $weight $restric , a(occsoc_num) vce(cluster statefip)
			outreg2 log_vet_var using replicationwocovars, append 
			
			
			eststo: reghdfe dneed4 log_vet_var     i.year $weight $restric , a(occsoc_num statefip) vce(cluster statefip)
			outreg2 log_vet_var using replicationwocovars, append 
			
			
			eststo: reghdfe dneed4 log_vet_var_bp     i.year $weight $restric , a(occsoc_num ) vce(cluster statefip)
			outreg2 log_vet_var_bp using replicationwocovars, append 
			
				
			eststo: reghdfe dneed4 log_vet_var_bp     i.year $weight $restric , a(occsoc_num statefip ) vce(cluster statefip)
			outreg2 log_vet_var_bp using replicationwocovars, append 
			
			
			
			eststo: reghdfe dneed4 dvet_supdem_bgt_bp     i.year $weight $restric , a(occsoc_num) vce(cluster statefip)
			outreg2 dvet_supdem_bgt_bp using replicationwocovars, append 
			
			
			eststo: reghdfe dneed4 dvet_supdem_bgt_bp     i.year $weight $restric , a(occsoc_num statefip) vce(cluster statefip)
			outreg2 dvet_supdem_bgt_bp using replicationwocovars, append 
			
			
			eststo: reghdfe dneed4     i.year (dBGTsupdemrate=dvet_supdem_bgt_bp)  $weight $restric , a(occsoc_num) vce(cluster statefip)
			outreg2 dBGTsupdemrate using replicationwocovars, append 
			
			
			eststo: reghdfe dneed4     i.year  (dBGTsupdemrate=dvet_supdem_bgt_bp)  $weight $restric , a(occsoc_num statefip) vce(cluster statefip)
			outreg2 dBGTsupdemrate using replicationwocovars, append  excel
			
			
			
			